#ifndef __FLASH_RW__H__
#define __FLASH_RW__H__


#include "compile_option.h"

#ifdef AW_86802

#define CHANNELCAL_DATA_GAINFACTOR  1000
#define ONE_CALI_PARA_SIZE          4
#define TOTAL_CALI_PARA_SIZE        (PHY_CH_COUNT * ONE_CALI_PARA_SIZE + 2)


#define PROFILE_BLOCK_SEC_START			(48 << 1)
#define PROFILE_BLOCK_SEC_SIZE			(1 << 9)

#define BLOCK_MIN						0
#define BLOCK_MAX						21

//////////////////////block location define//////////////////
#define CALIBRATION_BLOCK               21

#define MODEL1_2_BLOCK                  20
#define MODEL3_4_BLOCK                  19
#define MODEL5_6_BLOCK                  18
#define MODEL7_8_BLOCK                  17
#define MODEL9_10_BLOCK                 16
#define MODEL11_12_BLOCK                15
#define MODEL13_14_BLOCK                14
#define MODEL15_16_BLOCK                13

#define FW_CONFIG_BLOCK                 12
#define AP_TEST_BLOCK                   11

#define MODEL_BLOCK_MAX                 8
#define ONE_MODE_MAX_SIZE               256

#ifndef CONST_LARGE_MODEL_LEN
#define CONST_LARGE_MODEL_LEN           250
#endif
//////////////////////block location define//////////////////



extern u8 temp_buff[];

extern u8 hal_read_all_cali_from_flash(u8 *pbuf);
extern u8 hal_write_cali_2_flash_enforce(u8 *pbuf);
extern u8 hal_read_single_model_from_flash(u8 index, u8 *pbuf);
extern u8 hal_write_single_model_2_flash(u8 *pbuf);

extern u8 hal_write_large_model_2_flash(u8 *pbuf);
extern u8 hal_read_large_model_from_flash(u8 index, u8 *pbuf);
extern u8 hal_write_ap_test_2_flash(u8 *pbuf);
extern u8 hal_read_ap_test_from_flash(u8 *pbuf);
extern u8 init_large_model_from_flash(AdcType *des_buff, u8 block_id, u8 len);

extern void hal_flash_para_init(void);

void init_cfg_from_flash(void);
void hal_write_cfg_2_flash(void);


#endif
#endif
